import React from 'react'
import { View } from '@tarojs/components'
import { Observer, useLocalStore } from 'mobx-react'
import './index.scss'
// import { ImageEle } from '@/components/Image'
import { Empty } from '@/components/Empty';
import { Panel } from '@/components/Panel'
import { UserRateEle } from './components/UserRate'
import { RateModel } from '@/model/RateModel'
import { useDidShow } from '@tarojs/taro'
import { toDate } from '@/utils/utils'


// {
//     main_pic: 'https://img.yzcdn.cn/vant/cat.jpeg',
//     nick: '要都是考虑自动挡车型',
//     id: 0,
//     cost_price: 0,
//     name: '要都是考虑自动挡车型',
//     price: 89,
//     brief: '',
//     market_price: 9

// }

/**
 * 我的评论
 */
export default () => {
    const store = useLocalStore(() => RateModel)
    useDidShow(() => {
        store.getData()
    })

    return (
        <Observer>
            {
                () => <View className="xxm-me-rate">
                    {store.list.length > 0 && store.list.map((_, idx) => {
                        return (
                            <Panel key={idx}>
                                <UserRateEle
                                    time={toDate(_.create_at)}
                                    title={_.m_user.nickname}
                                    content={_.content}
                                    rate={_.grade}
                                    avater={_.m_user.avatar}
                                    goods={_.order.order_goods}
                                >
                                </UserRateEle>
                            </Panel>
                        )
                    })}

                    {store.list.length === 0 &&
                        <Empty
                            img="http://xmmi.oss-cn-beijing.aliyuncs.com/icon/no-data.png"
                            desc="暂无相关数据"
                        />
                    }
                </View>
            }
        </Observer>
    )
}